/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2022-11-17
 * Time:10:33
 */
public class MyCircularQueue {
    public int []elem;
    public int front;
    public int tail;

    public MyCircularQueue(int k) {
        elem=new int[k+1];
    }
    public boolean enQueue(int value) {
        if(isFull()){
            return false;
        }else{
            elem[tail]=value;
            tail=(tail+1)%elem.length;
            return true;
        }
    }

    public boolean deQueue() {
        if(isEmpty()){
            return false;
        }else{
            front=(front+1)%elem.length;
            return true;
        }
    }

    public int Front() {
        if(isEmpty()){
            return -1;
        }else{
            return elem[front];
        }
    }

    public int Rear() {
        if(isEmpty()){
            return-1;
        }else{
            if(tail==0){
                return elem[elem.length-1];
            }else{
                return elem[tail-1];
            }
        }
    }

    public boolean isEmpty() {
        if(front==tail){
            return true;
        }else{
            return false;
        }
    }

    public boolean isFull() {
        if((tail+1)%elem.length==front){
            return true;
        }
        return false;
    }
}
